﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.IO;

namespace Per_pixel_OCR
{
    [Serializable]
    public enum DigitType
    { 
        TRAIN = 0,
        TEST_FAILED = 1,
        TEST_SUCCESS = 2,
        TEST_UNKNOWN = 3
    }

    [Serializable]
    public class Digit
    {
        public int DigitID { get; private set; }
        public DigitType DigitType { get; set; }
        public byte DigitValue { get; private set; }        
        
        public byte[,] OriginalGrayscaleMatrix { get; private set; } 
        public byte[,] TagMatrix { get; private set; } // 255 is white, 254 unknown tag, [0-253] tags...
        
        public List<Pixel> NonZeroPixels { get; private set; }

        public Digit(int digitID, byte digitValue, byte[,] originalMatrix, byte[,] tagMatrix)
        {
            this.DigitValue = digitValue;
            this.OriginalGrayscaleMatrix = originalMatrix;
            this.TagMatrix = tagMatrix;
            this.DigitID = digitID;

            this.NonZeroPixels = new List<Pixel>();

            for (int i = 0; i < this.OriginalGrayscaleMatrix.GetLength(0); i++)
                for (int j = 0; j < this.OriginalGrayscaleMatrix.GetLength(1); j++)
                    if (this.OriginalGrayscaleMatrix[i, j] > 8)
                        NonZeroPixels.Add(new Pixel(this, (byte)j, (byte)i));
        }

        public override string ToString()
        {
            return "Digit: " + this.DigitValue.ToString();
        }
    }
}
